<template>
	<!-- 人工入账流水 -->
	<div class="financeManualFlow" v-loading="loading">
		<h3>人工入账流水</h3>
		<AreaWarp :padding="true">
	        <SearchWarp :label="'姓名'">
	        	<el-input v-model.trim="searchInfo.realName"    placeholder="请输入用户姓名"></el-input>
	        </SearchWarp>
	        <SearchWarp :label="'手机号'">
	          <el-input v-model.trim="searchInfo.mobile" maxlength="11" placeholder="请输入手机号码"></el-input>
	        </SearchWarp>
	        <SearchWarp :label="'订单ID'">
	          <el-input v-model.trim="searchInfo.borrowId" maxlength="11" placeholder="请输入手机号码"></el-input>
	        </SearchWarp>
	        <SearchWarp :label="'是否操作结案'">
		        <el-select v-model="searchInfo.flag"  placeholder="请选择">
		          <el-option v-for="item in flagOptions"
		                     :key="item.value"
		                     :label="item.label"
		                     :value="item.value">
		          </el-option>
		        </el-select>
		    </SearchWarp>
	        <SearchWarp :label="'还款时间'">
	          	<el-date-picker v-model="searchInfo.time" type="daterange" :picker-options="pickerOptions" range-separator="-" start-placeholder="开始日期"
	                          end-placeholder="结束日期" :editable="false"></el-date-picker>
	        </SearchWarp>
	        <!-- <SearchWarp v-model="searchInfo.operator" :label="'操作员'">
		        <el-select placeholder="请选择">
		          <el-option v-for="item in operatorOptions"
		                     :key="item.value"
		                     :label="item.label"
		                     :value="item.value">
		          </el-option>
		        </el-select>
		    </SearchWarp> -->
	        <BtnWarp>
	          <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
	          <el-button type="info" icon="el-icon-delete" @click="reset">重置</el-button>
	        </BtnWarp>
	    </AreaWarp>

	   	<AreaTitleWarp :title="'订单列表'">

      	</AreaTitleWarp>

      <!--搜索结果区域-->
      <AreaWarp :padding="false">
        <el-table size="mini" :data="tableInfo.list" style="width: 100%" class="pub-table" header-row-class-name="pub-table-header-row" header-cell-class-name="pub-table-header-cell"
          tooltip-effect="dark"
        >
          <el-table-column prop="id" label="流水ID"></el-table-column>
          <el-table-column prop="borrowId" label="订单ID"></el-table-column>
          <el-table-column prop="appId" label="产品" :formatter="formatter_product"></el-table-column>
          <el-table-column prop="realName" label="姓名"></el-table-column>
          <el-table-column prop="mobile" label="手机号" min-width="120"></el-table-column>
          <el-table-column prop="thisAmount" label="本次入账金额" min-width="120"></el-table-column>
          <el-table-column prop="repaySuccessTimestamp" label="还款时间" min-width="150" :formatter="formatter_timeYMDHMS"></el-table-column>
          <el-table-column prop="gmtCreate" label="入账时间" min-width="150" :formatter="formatter_timeYMDHMS"></el-table-column>

          <el-table-column prop="payFlag" label="是否操作结案" min-width="90" :formatter="filter_flag"></el-table-column>

          <el-table-column prop="remark" label="入账备注" min-width="180"></el-table-column>
          <el-table-column prop="userName" label="操作人员" min-width="120"></el-table-column>
        </el-table>
        <el-pagination
          layout="total,sizes,prev, pager, next, jumper" class="pub-page"
          :current-page="searchInfo.page"
          :page-sizes="[20,50,100]"
          :page-size="searchInfo.size"
          :total="tableInfo.total"
          @current-change="search"
          @size-change="handleSizeChange"
        >
        </el-pagination>
      </AreaWarp>
	</div>
</template>
<script>
	import Finance  from '../../../assets/js/finance.js'
	export default({
		data(){
			return{
				searchInfo:{
					realName: '',
					mobile: '',
					time: '',
					flag:'-1',
					borrowId: '',  //订单Id
					operator: '',
					size:20,
					page:1,
				},
				loading: false,
				statusOptions:[],
				tableInfo:{
					list:[],
					total: 0,
					page:0,
					size:0
				},
				flagOptions:[
					{
						value: '-1',
          				label: '全部'
					},
					{
						value: '0',
          				label: '否'
					},{
						value: '1',
          				label: '是'
					}
				],
				operatorOptions:[],
			}
		},
		methods:{
			userlist(){
				let that = this;
				return new Promise(function(resolve,reject){
					that.ajaxJson({
			          	url: '/static/finance/userlist',
			          	success: function (res) {
			            	if (res.code == '0') {
			            		res.data.forEach(function(item,index){
			            			that.operatorOptions.push({
			            				value: item.id,
			            				label: item.realName
			            			})
			            		})
			            		resolve()
			            	}
			          	}
			        })
				})
			},
			handleSizeChange(val){
				let that = this;
				that.searchInfo.size = val;
            	that.searchInfo.page = 1;
            	that.search()
			},
			search(currentPage){
				let that = this;
				that.searchInfo.page = typeof currentPage == 'number' ? currentPage : 1;
				let x = {
					realName: that.searchInfo.realName,
					mobile: that.searchInfo.mobile,
					size: that.searchInfo.size,
					page: that.searchInfo.page,
					time: that.searchInfo.time,
					flag: that.searchInfo.flag,
					borrowId: that.searchInfo.borrowId
				}
				let finance = new Finance(x)
				let reqData = finance.getState()
				if(reqData.code){
					that.showMsg(reqData.message,'error')
					return
				}
				that.loading = true;
				that.ajaxJson({
		          url: '/finance/recordlist',
		          data:reqData,
		          success: function (res) {
		            if (res.code == '0') {
		            	that.tableInfo = res.data;
		            }
		            that.loading = false;
		          }
		        })
			},
			reset(){
				let that = this;
				that.searchInfo = {
					realName: '',
					mobile: '',
					time: '',
					flag:'-1',
					borrowId: '',  //订单Id
					operator: '',
					size:20,
					page:1,
				}
				that.search();
			},
			filter_flag(row, column, cellValue, index){
                switch(cellValue){
                  case '0':
                  case 0:
                      return '否';
                  case 1:
                      return '是';
                }
            },

		},
		created(){
			let that = this;
			Promise.all([
				that.userlist()
			]).then(function(){
				that.search();
			})


		},
		beforeCreate(){
			let that = this;

		}
	})
</script>
<style lang="less">
	.financeManualFlow{
		.inputWidth{
			width:120px;
		}
	}
</style>
